<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/include/page.jsp"%>
<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8">
		<title>添加邮件 - 管邮件管理 - 邮件威胁检测</title>
		<meta name="keywords" content="添加邮件 - 管邮件管理 - 邮件威胁检测">
		<meta name="description" content="添加邮件 - 管邮件管理 - 邮件威胁检测">
		<%@ include file="/common/include/title_back.jsp" %>
	</head>
	<body>
		<nav class="breadcrumb">
			<i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>
			邮件管理 <span class="c-gray en">&gt;</span> 邮件添加 <a
				class="btn btn-success radius r"
				style="line-height: 1.6em; margin-top: 3px"
				href="javascript:location.replace(location.href);" title="刷新"><i
				class="Hui-iconfont">&#xe68f;</i></a>
		</nav>
		<article class="page-container">
			${requestScope.info }
			<form class="form form-horizontal" id="form-admin-add" 
				action="${rootPath}/back/EmailBackServlet?method=emailInsertSubmit" method="post">
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">
						<span class="c-red">*</span>收件人：
					</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" value="${requestScope.email.rcpt }" placeholder="" id="rcpt" name="rcpt">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">
						<span class="c-red">*</span>发件人：
					</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" value="${requestScope.email.sender }" placeholder="" id="sender" name="sender">
					</div>
				</div>
			
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">
						<span class="c-red">*</span>发信人：
					</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" value="${requestScope.email.fromname }" placeholder=""
							id="fromname" name="fromname">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">
						<span class="c-red">*</span>ip：
					</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" value="${requestScope.email.region }" placeholder=""
							id="region" name="region">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">
						<span class="c-red">*</span>登录ip：
					</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" value="${requestScope.email.ip }" placeholder=""
							id="ip" name="ip">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">
						<span class="c-red">*</span>url：
					</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" class="input-text" value="${requestScope.email.url }" placeholder=""
							id="url" name="url">
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">
						<span class="c-red">*</span>发信时间：
					</label>
					<div class="formControls col-xs-8 col-sm-9">
						<input type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" 
						id="sendTime" name="sendTime" readonly="readonly" class="input-text" 
					 	style="width: 160px;"
					 	value="${requestScope.sendTime }"
						>
					</div>
				</div>
				<div class="row cl">
					<label class="form-label col-xs-4 col-sm-3">描述：</label>
					<div class="formControls col-xs-8 col-sm-9">
						<textarea id="content" name="content" cols="" rows="" class="textarea"
							placeholder="说点什么...100个字符以内" dragonfly="true"
							onKeyUp="$.Huitextarealength(this,100)">${requestScope.email.content }</textarea>
						<p class="textarea-numberbar">
							<em class="textarea-length">0</em>/100
						</p>
					</div>
				</div>
				<div class="row cl">
					<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
						<input class="btn btn-primary radius" type="submit"
							value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
					</div>
				</div>
			</form>
		</article>
		<%@ include file="/common/include/footer_back.jsp"%>
	</body>
</html>
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="${rootPath }/common/resource/H-ui.admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="${rootPath }/common/resource/H-ui.admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="${rootPath }/common/resource/H-ui.admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript">
	$(function() {
		$('.skin-minimal input').iCheck({
			checkboxClass : 'icheckbox-blue',
			radioClass : 'iradio-blue',
			increaseArea : '20%'
		});
		
		<%--
			表单的Id是为了验证哪个表单(from) 
		--%>
		$("#form-admin-add").validate(
		{
			rules : {
				trueName : {
					required : true,
					/* 最小长度 */
					minlength : 2,
					/* 最大长度 */
					maxlength : 16
				},
				password : {
					required : true,
				},
				/* 确认密码
					确认密码和密码一样
				*/
				confirmPass : {
					required : true,
					/* equal:to和谁相诠,#password;id选择器 */
					equalTo : "#password"
				},
				sex : {
					required : true,
				},
				phone : {
					required : true,
					isPhone : true,
				},
				/* 验证文本框:id: */
				email : {
					/* 必填 */
					required : true,
					/* 验证是的email;正则表达式,内部已经写好; */
					email : true,
				},
				adminRole : {
					required : true,
				},
			},
			onkeyup : false,
			focusCleanup : true,
			success : "valid",
			submitHandler : function(form) {
				/* jquery版本的ajax
					当表单融入到h-ui-admin框架中,它期望ajax提交
					ajax提交,返回值一般是json
				*/
				$(form).ajaxSubmit(
				{
					type : 'post',
					url : "${rootPath}/back/EmailBackServlet?method=emailInsertSubmit",
					success : function(data) {
						//console.info("=====" + data)
						/* 因为返回的json中,有info属性 */
						layer.msg(
							data.info,
							{
								icon : 1,
								time : 5000,
							},
							function()
							{
									/* 主线程等待 */
									/* 弹出的选项卡是否关闭的问题 */
									/* 如果添加成功的时候关闭或者关闭 */
									if(data.code == '0')
									{
										var index = parent.layer
												.getFrameIndex(window.name);
										parent.$('.btn-refresh').click();
										parent.layer.close(index);
									}
							}
						);
					},
					error : function(
							XmlHttpRequest,
							textStatus,
							errorThrown) {
						layer.msg(
							'error!',
							{
								icon : 1,
								time : 1000
							});
					},
					/* 期望ajax的返回值,是json,
					让jquery当成json处理*/
					dataType:"json"
				});
				
				/* 关闭当前选项卡弹出的框框
					当添加成功的时候关闭,
					添加失败不要关闭或者关闭
				*/
				/* var index = parent.layer
						.getFrameIndex(window.name);
				parent.$('.btn-refresh').click();
				parent.layer.close(index); */
			}
		});
	});
</script>
<!--/请在上方写此页面业务相关的脚本-->